import request from '@/utils/request'

// 查询零工报工列表
export function listOddjob(query) {
  return request({
    url: '/sl/oddjob/list',
    method: 'get',
    params: query
  })
}

// 查询历史报工
export function listHOddjob(query) {
  return request({
    url: '/sl/oddjob/hlist',
    method: 'get',
    params: query
  })
}

// 查询零工报工详细
export function getOddjob(oddjobId) {
  return request({
    url: '/sl/oddjob/' + oddjobId,
    method: 'get'
  })
}

// 新增零工报工
export function addOddjob(data) {
  return request({
    url: '/sl/oddjob',
    method: 'post',
    data: data
  })
}

// 修改零工报工
export function updateOddjob(data) {
  return request({
    url: '/sl/oddjob',
    method: 'put',
    data: data
  })
}

// 删除零工报工
export function delOddjob(oddjobId) {
  return request({
    url: '/sl/oddjob/' + oddjobId,
    method: 'delete'
  })
}

// 新增打开报工单页面是获取页面上的选项内容
export function getOddjobOptions(data) {
  return request({
    url: '/sl/oddjob/option',
    method: 'get',
    params: data
  })
}

//防止选人重复添加
export function isUniqueJobUser(arr,obj){
  for(var i = 0; i < arr.length; i++){
    if(arr[i].omemberUser===obj.omemberUser){
        return false;
    }
  }
  return true;
}

// 更新报工单开始结束时间
export function updateOddjobDateTime(data) {
  return request({
    url: '/sl/oddjob/upd',
    method: 'put',
    data: data
  })
}

//提交整张报工单
export function submitDateOddjobs(data) {
  return request({
    url: '/sl/oddjob/daterws',
    method: 'post',
    data: data
  })
}

// 根据报工单查询报工项
export function listOddjobByrfworkId(rfworkId) {
  return request({
    url: '/sl/oddjob/rfw/' + rfworkId,
    method: 'get'
  })
}

// 查询所有未提交的报工项列表
export function listNoSubmitOddjob(query) {
  return request({
    url: '/sl/oddjob/notlist',
    method: 'get',
    params: query
  })
}

